﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HF.Framework.DataClientDBAgent;
using HF.Business.Sale;//封装销售业务的类
using HF.Permission.Data;
using HF.Framework.Web;

public partial class CustomerMgr : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private void bind()
    {
        if (rbtCode.Checked)
        {
            DataTable dt = Customers.GetCustomerTableLikeId(tbxSearch.Text);
            gvCustomer.DataSource = dt;
            gvCustomer.DataBind();
        }
        else
        {
            DataTable dt = Customers.GetCustomerTableLikeName(tbxSearch.Text);
            gvCustomer.DataSource = dt;
            gvCustomer.DataBind();
        }
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        bind();
       
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
      
    }
    
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string userid=this.User.Identity.Name.ToString();
        if (PowerData.IsPower(userid, "021603") == false)
        {
            WorkDialog.ShowMessage(this, userid + "没有删除的权限!");
            return;
        }
        foreach (GridViewRow gvr in gvCustomer.Rows)
        {
            CheckBox ch = (CheckBox)gvr.FindControl("ItemCheckBox");
            if (ch.Checked)
            {
                Customers.Delete(gvCustomer.DataKeys[gvr.DataItemIndex].Value.ToString());
                
            }
        }
        bind();

       
    }
}
